﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Printing;
using System.Windows.Forms;
namespace Group16.Class_Library
{
    static public class PrintSupport
    {
        static private PrintDocument _document;
        static private PrintDocument Document
        { get { return _document; } }
        static PrintSupport()
        {
            _document = new PrintDocument();
            _document.PrintPage += print_PrintPage;
        }
        static public void PageSetup()
        {
            PageSetupDialog dlg = new PageSetupDialog();
            dlg.Document = Document;
            dlg.ShowDialog();
        }
        static public void PrintPreview()
        {
            PrintPreviewDialog dlg = new PrintPreviewDialog();
            dlg.Document = Document;
            dlg.ShowDialog();
        }
        static public void Print()
        {
            PrintDialog dlg = new PrintDialog();
            dlg.Document = Document;
            if (dlg.ShowDialog() == DialogResult.OK)
                Document.Print();
        }
        static void print_PrintPage(object sender, PrintPageEventArgs e)
        {
            Form f = Application.OpenForms[0];
            if (f != null && f.IsMdiContainer)
                f = f.ActiveMdiChild;

        }
    }
}
